#include <iostream>
#include <memory>

class Fruit {
public:
    virtual void name() = 0;
};

class Apple : public Fruit {
public:
    virtual void name() override {
        std::cout << "apple\n";
    }
};

class Banana : public Fruit {
public:
    virtual void name() override {
        std::cout << "banana\n";
    }       
};

class FruitFactory {
public:
    static std::shared_ptr<Fruit> create(const std::string name) {
        if (name == "apple") {
            return std::make_shared<Apple>();
        }
        else{
            return std::make_shared<Banana>();
        }
    }
};

int main() {
    std::shared_ptr<Fruit> fruit = FruitFactory::create("apple");
    fruit->name();
    fruit = FruitFactory::create("banana");
    fruit->name();
    return 0;
}
